
set more off
clear
est clear

****************************************************************************************************
**************/Treatment effect  estimates / *************************************
****************************************************************************************************


// StewardShare I and II

//SS II
use "$dta/SS1and2.dta", clear

gen primingtreatment = primingvariation >= 2
replace primingtreatment = . if agvise == 2   //priming treatment only in SSI

rename personid person_id

** StewardShare II

* glm with controls *

 glm realbid slidervariation i.gender i.itemnum totalacres age productionyears rowcropacres crpindicator isagweek i.state  inag1and2 if agvise == 2, link(logit) family(binomial) vce(cluster person_id) nolog

estpost margins, dydx(slidervariation age) 
eststo glmwC_S2
su realbid if e(sample) & slidervariation == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "Yes"

* glm with no controls  *

glm realbid slidervariation  if agvise == 2, link(logit) family(binomial) vce(cluster person_id) nolog

estpost margins, dydx(slidervariation) 
eststo glmwoC_S2
su realbid if e(sample) & slidervariation == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "No"

* ols with controls *

reg realbid slidervariation i.gender i.itemnum totalacres age productionyears rowcropacres crpindicator isagweek i.state  inag1and2 if agvise == 2, vce(cluster person_id) 

eststo olswC_S2
su realbid if e(sample) & slidervariation == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "Yes"

* ols with no controls  *

reg realbid slidervariation  if agvise == 2,  vce(cluster person_id) 

eststo olswoC_S2
su realbid if e(sample) & slidervariation == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "No"


*** Steward Share I ***

* glm with controls *
glm realbid slidervariation  i.gender i.itemnum totalacres age productionyears rowcropacres crpindicator isagweek i.state i.primingtreatment inag1and2  if agvise == 1, link(logit) family(binomial) vce(cluster person_id) nolog

estpost margins, dydx(slidervariation age)
eststo glmwC_S1
su realbid if e(sample) & slidervariation == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "Yes"


*glm with no controls
glm realbid slidervariation i.primingtreatment if agvise == 1, vce(cluster person_id) 

estpost margins, dydx(slidervariation)
eststo glmwoC_S1
su realbid if e(sample) & slidervariation == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "No"

* ols with controls *
reg realbid slidervariation i.gender i.itemnum totalacres age productionyears rowcropacres crpindicator isagweek i.state i.primingtreatment inag1and2 if agvise == 1,  vce(cluster person_id) 

eststo olswC_S1
su realbid if e(sample) & slidervariation == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "Yes"

* ols with nno controls *
reg realbid slidervariation i.primingtreatment if agvise == 1, vce(cluster person_id) 

eststo olswoC_S1
su realbid if e(sample) & slidervariation == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "No"

// (StewardShare III)

* glm with controls

use "$dta/SS3.dta", clear

glm fracbid default knowledge steward  age agyears owner i.gender i.state i.iscrp i.auction, link(logit) family(binomial) vce(cluster person_id)

estpost margins, dydx(default age)
eststo glmwC_S3
su fracbid if e(sample) & default == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "Yes"

* glm with no controls (except with controls for other treatments)

glm fracbid default knowledge steward  , link(logit) family(binomial) vce(cluster person_id)

estpost margins, dydx(default)
eststo glmwoC_S3
su fracbid if e(sample) & default == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "No"

* ols with controls

reg fracbid default knowledge steward  age agyears owner i.gender i.state i.iscrp i.auction,  vce(cluster person_id)

eststo olswC_S3
su fracbid if e(sample) & default == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "Yes"

* ols with no controls (except with controls for other treatments)

reg fracbid default knowledge steward  , vce(cluster person_id)

eststo olswoC_S3
su fracbid if e(sample) & default == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "No"

******* Pooled estimates **********
// With AgVise and HogVise
use "$dta/SSpooled.dta", clear 

*glm with controls 

glm fracbid default  age agyears owner i.gender i.state i.iscrp i.itemnum i.agvise, link(logit) family(binomial) vce(cluster person_id)

estpost margins, dydx(default age)
eststo glmwC_P
su fracbid if e(sample) & default == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "Yes"


*glm with no controls 

glm fracbid default  i.agvise, link(logit) family(binomial) vce(cluster person_id)

estpost margins, dydx(default)
eststo glmwoC_P
su fracbid if e(sample) & default == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "No"

*ols with controls 

reg fracbid default  age agyears owner i.gender i.state i.iscrp i.itemnum i.agvise, vce(cluster person_id)

eststo olswC_P
su fracbid if e(sample) & default == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "Yes"

*ols with no controls 

reg fracbid default  i.agvise,  vce(cluster person_id)

eststo olswoC_P
su fracbid if e(sample) & default == 0
estadd scalar depmean = r(mean)
estadd scalar depsd = r(sd)
estadd local hasC "No"

************* output tables ************************

***** glm resutls *****


#delimit ;
esttab  glmwoC_S1 glmwC_S1 glmwoC_S2 glmwC_S2 glmwoC_S3 glmwC_S3 glmwoC_P glmwC_P
	using "$outputs/01_MainEffect_glmtreateffect.tex", 
	replace b(2) ci(2) level(95) label nostar
	rename(slidervariation b default b)
	keep(b)
	coeflabels(b "Starting Anchor at 100\%")
	stats(dumm1 depmean depsd N , fmt(%9.0gc  %03.2f %03.2f %9.0gc) 
		labels("Control group:"  "  - Mean" "  - Std. dev." "Observations")) 
	mgroups("StewardShares I" "StewardShares II"  "StewardShares III" "Pooled", 
		pattern(1 0 1 0 1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(})   
     span erepeat(\cmidrule(lr){@span}) )
	nomtitles nodepvar
	indicate(Controls = age)
	nonote  booktabs wrap varwidth(20) width(\hsize)
	;

#delimit cr 


***** ols results *****

#delimit ;
esttab  olswoC_S1 olswC_S1 olswoC_S2 olswC_S2 olswoC_S3 olswC_S3 olswoC_P olswC_P
	using "$outputs/01_MainEffect_olstreateffect.tex", 
	replace b(2) ci(2) level(95) label nostar
	rename(slidervariation b default b)
	keep(b)
	coeflabels(b "Starting Anchor at 100\%")
	stats(dumm1 depmean depsd N , fmt(%9.0gc  %03.2f %03.2f %9.0gc) 
		labels("Control group:"  "  - Mean" "  - Std. dev." "Observations")) 
	mgroups("StewardShares I" "StewardShares II"  "StewardShares III" "Pooled", 
		pattern(1 0 1 0 1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(})   
     span erepeat(\cmidrule(lr){@span}) )
	nomtitles nodepvar
	indicate(Controls = age)
	nonote  booktabs wrap varwidth(20) width(\hsize)
	;

#delimit cr 


